from flask import Flask,request
from flask_sqlalchemy import SQLAlchemy
from cons import Config

app=Flask(__name__)
app.config.from_object(Config)
db=SQLAlchemy(app)

class User(db.Model):
    __tablename__='user'
    id = db.Column(db.Integer,primary_key=True,autocrement=True)
    name=db.Column(db.string(30),default='')
    sex=db.Column(db.Boolean,default=1)
    score=db.Column(db.Float,default=1)

# db.drop_all()
db.create_all()

@app.route('/userM',methods=['POST','GET'])
def userM():
    if request.method=='POST':
        name=request.form.get('name')
        score=request.form.get('score')
        user=User(name=name,score=score,sex=1)
        db.session.add(user)
        db.session.commit()
        return 'ok'
    else:
        users=User.query.all()
        for i in users:
            print(i.name)
            return 'ok'


if __name__=='__main__':
    app.run()